<?php
namespace app\serveradv\validate;

use \app\manage\validate\BaseValidate;
/**
 * @Author: Marte
 * @Date:   2017-05-27 16:25:13
 * @Last Modified by:   Marte
 * @Last Modified time: 2017-05-27 16:34:29
 */
class Adv extends BaseValidate
{
    protected $rule = [
        'c_id'          => ['require', 'number', 'egt' => '0'],
        'name'          => ['require'],
        'pic_id'        => ['require', 'number'],
        'relative_path' => ['require'],
        'absolute_path' => ['require'],
        'jump_url'      => ['require', 'url'],
        'add_user_id'   => ['require'],
        'start_time'    => ['require'],
        'end_time'      => ['require'],
        'status'        => ['in'=>['-1','0','1']],
        'audit_status'  => ['in'=>['-1','0','1']],
        'pic_id'        => ['require'],
        'listRows'      => ['number','gt' => '0'],
    ];

    protected $message = [
        'c_id.require'          => '请填写分类id',
        'c_id.number'           => '分类id请填写数字',
        'c_id.gt'               => '分类id必须大于或等于0',
        'pic_id'                => '请填写上传图片id',
        'name.require'          => '请填写广告位名称',
        'relative_path.require' => '请填写图片相对路径',
        'absolute_path.require' => '请填写图片绝对路径',
        'jump_url.require'      => '请填写广告位跳转地址',
        'jump_url.url'          => '请填写广告位有效url地址',
        'add_user_id.require'   => '请填写添加人id',
        'start_time.require'    => '请填写上架时间',
        'end_time.require'      => '请填写下架时间',
        'status.in'             => 'status只能是-1、0或1',
        'audit_status.in'       => 'audit_status只能是-1、0或1',
        'pic_id.require'        => '图片id必须填写',
        'listRows.gt'           => '分页条数需大于零的整数',
    ];

    protected $scene = [
        'add'        => ['c_id', 'name', 'pic_id', 'relative_path', 'absolute_path', 'jump_url', 'add_user', 'pic_id'],
        'edit'       => ['id', 'c_id' => ['number', 'egt' => '0'], 'pic_id' => ['number'], 'jump_url' => ['url']],
        'delete'     => ['id'],
        'cid'        => ['c_id'],
        'status'     => ['audit_status'],
        'advClassList' => ['c_id'=>['integer','gt'=>0], 'action'=>['min'=>2]],
    ];
}